﻿<template>
  <a-modal
    title="新增客户管理"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item label="卡号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入卡号 " v-decorator="['icNo', {rules: [{required: true, message: '请输入卡号 ！'}]}]" />
        </a-form-item>
        <a-form-item label="姓名 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入姓名 " v-decorator="['patientName', {rules: [{required: true, message: '请输入姓名 ！'}]}]" />
        </a-form-item>
        <a-form-item label="性别 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入性别 " v-decorator="['patientSex', {rules: [{required: true, message: '请输入性别 ！'}]}]" />
        </a-form-item>
        <a-form-item label="生日 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-date-picker style="width: 100%" placeholder="请选择生日 " v-decorator="['birthday',{rules: [{ required: true, message: '请选择生日 ！' }]}]" @change="onChangebirthday"/>
        </a-form-item>
        <a-form-item label="操作日期 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-date-picker style="width: 100%" placeholder="请选择操作日期 " v-decorator="['operDate']" @change="onChangeoperDate"/>
        </a-form-item>
        <a-form-item label="建卡日期 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-date-picker style="width: 100%" placeholder="请选择建卡日期 " v-decorator="['foundDate']" @change="onChangefoundDate"/>
        </a-form-item>
        <a-form-item label="建卡人 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入建卡人 " v-decorator="['foundName']" />
        </a-form-item>
        <a-form-item label="操作员编码 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入操作员编码 " v-decorator="['operCode']" />
        </a-form-item>
        <a-form-item label="操作员 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入操作员 " v-decorator="['operName']" />
        </a-form-item>
        <a-form-item label="拼音码 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入拼音码 " v-decorator="['inputCode']" />
        </a-form-item>
        <a-form-item label="五笔码 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入五笔码 " v-decorator="['inputCodeWb']" />
        </a-form-item>
        <a-form-item label="VIP标志，没什么用 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入VIP标志，没什么用 " v-decorator="['vipFlag']" />
        </a-form-item>
        <a-form-item label="身份证号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入身份证号 " v-decorator="['patientId', {rules: [{required: true, message: '请输入身份证号 ！'}]}]" />
        </a-form-item>
        <a-form-item label="地址 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入地址 " v-decorator="['address', {rules: [{required: true, message: '请输入地址 ！'}]}]" />
        </a-form-item>
        <a-form-item label="电话 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入电话 " v-decorator="['phone', {rules: [{required: true, message: '请输入电话 ！'}]}]" />
        </a-form-item>
        <a-form-item label="邮箱 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入邮箱 " v-decorator="['email']" />
        </a-form-item>
        <a-form-item label="邮编 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入邮编 " v-decorator="['zip']" />
        </a-form-item>
        <a-form-item label="有效期 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-date-picker style="width: 100%" placeholder="请选择有效期 " v-decorator="['validDate']" @change="onChangevalidDate"/>
        </a-form-item>
        <a-form-item label="卡状态 0 注销 1正常 2停用 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入卡状态 0 注销 1正常 2停用 " v-decorator="['icStatus']" />
        </a-form-item>
        <a-form-item label="CRMID " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入CRMID " v-decorator="['siCode', {rules: [{required: true, message: '请输入CRMID ！'}]}]" />
        </a-form-item>
        <a-form-item label="住院号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入住院号 " v-decorator="['admNo']" />
        </a-form-item>
        <a-form-item label="门诊号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入门诊号 " v-decorator="['outpNo']" />
        </a-form-item>
        <a-form-item label="是否打折 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入是否打折 " v-decorator="['rebateType']" />
        </a-form-item>
        <a-form-item label="折扣 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入折扣 " v-decorator="['rebate']" />
        </a-form-item>
        <a-form-item label="余额 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入余额 " v-decorator="['icFee']" />
        </a-form-item>
        <a-form-item label="累计消费 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入累计消费 " v-decorator="['consumeFee']" />
        </a-form-item>
        <a-form-item label="卡类别 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入卡类别 " v-decorator="['icType']" />
        </a-form-item>
        <a-form-item label="就诊号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入就诊号 " v-decorator="['icVisitNo']" />
        </a-form-item>
        <a-form-item label="联系人地址 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入联系人地址 " v-decorator="['linkmanAddr']" />
        </a-form-item>
        <a-form-item label="关联卡卡号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入关联卡卡号 " v-decorator="['linkmanPhone']" />
        </a-form-item>
        <a-form-item label="关系 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入关系 " v-decorator="['relationship']" />
        </a-form-item>
        <a-form-item label="工作地址 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入工作地址 " v-decorator="['workAddr']" />
        </a-form-item>
        <a-form-item label="联系人 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入联系人 " v-decorator="['linkman']" />
        </a-form-item>
        <a-form-item label="套内折扣 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入套内折扣 " v-decorator="['rebate1']" />
        </a-form-item>
        <a-form-item label="备注 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入备注 " v-decorator="['remark']" />
        </a-form-item>
        <a-form-item label="咨询顾问 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入咨询顾问 " v-decorator="['consultant']" />
        </a-form-item>
        <a-form-item label="客户专员 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入客户专员 " v-decorator="['consultanter']" />
        </a-form-item>
        <a-form-item label="末次月经 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-date-picker style="width: 100%" placeholder="请选择末次月经 " v-decorator="['mensesDate']" @change="onChangemensesDate"/>
        </a-form-item>
        <a-form-item label="末次月经 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入末次月经 " v-decorator="['menses']" />
        </a-form-item>
        <a-form-item label="备注 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入备注 " v-decorator="['back1']" />
        </a-form-item>
        <a-form-item label="医院编码 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入医院编码 " v-decorator="['hosptailCode']" />
        </a-form-item>
        <a-form-item label="医院名称 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入医院名称 " v-decorator="['hosptailName']" />
        </a-form-item>
        <a-form-item label="" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入" v-decorator="['theCallFlag']" />
        </a-form-item>
        <a-form-item label="导入备注 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入导入备注 " v-decorator="['importantNote']" />
        </a-form-item>
        <a-form-item label="档案号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入档案号 " v-decorator="['danganNo']" />
        </a-form-item>
        <a-form-item label="APP卡号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入APP卡号 " v-decorator="['appIcCode']" />
        </a-form-item>
        <a-form-item label="" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入" v-decorator="['bzj']" />
        </a-form-item>
        <a-form-item label="医保备注" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入医保备注" v-decorator="['siRemark']" />
        </a-form-item>
        <a-form-item label="APPID " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入APPID " v-decorator="['appid']" />
        </a-form-item>
        <a-form-item label="CRM备注 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入CRM备注 " v-decorator="['crmRemarks']" />
        </a-form-item>
        <a-form-item label="账户余额 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入账户余额 " v-decorator="['accountfee']" />
        </a-form-item>
        <a-form-item label="产检标志 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入产检标志 " v-decorator="['cjbz']" />
        </a-form-item>
        <a-form-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入备注" v-decorator="['remark1']" />
        </a-form-item>
        <a-form-item label="1.不能退费、退卡；不开发票 2.不能退费、退卡、换卡 3.不能退费 4.不能退卡、换卡 5.不能开发票 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入1.不能退费、退卡；不开发票 2.不能退费、退卡、换卡 3.不能退费 4.不能退卡、换卡 5.不能开发票 " v-decorator="['icLevel']" />
        </a-form-item>
        <a-form-item label="会员卡类别 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入会员卡类别 " v-decorator="['icStyle']" />
        </a-form-item>
        <a-form-item label="建卡目的 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入建卡目的 " v-decorator="['createPurpose']" />
        </a-form-item>
        <a-form-item label="建卡科室 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入建卡科室 " v-decorator="['createDeptname']" />
        </a-form-item>
        <a-form-item label="" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入" v-decorator="['fallassessment']" />
        </a-form-item>
        <a-form-item label="退费原因 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入退费原因 " v-decorator="['cancleReason']" />
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
  import {
    IcInfoAdd
  } from '@/api/modular/main/IcInfoManage'

  export default {
    data () {
      return {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 15 }
        },
        birthdayDateString: '',
        operDateDateString: '',
        foundDateDateString: '',
        validDateDateString: '',
        mensesDateDateString: '',
        visible: false,
        confirmLoading: false,
        form: this.$form.createForm(this)
      }
    },
    methods: {
      // 初始化方法
      add (record) {
        this.visible = true
      },
      /**
       * 提交表单
       */
      handleSubmit () {
        const { form: { validateFields } } = this
        this.confirmLoading = true
        validateFields((errors, values) => {
          if (!errors) {
            for (const key in values) {
              if (typeof (values[key]) === 'object') {
                values[key] = JSON.stringify(values[key])
              }
            }
            values.birthday = this.birthdayDateString
            values.operDate = this.operDateDateString
            values.foundDate = this.foundDateDateString
            values.validDate = this.validDateDateString
            values.mensesDate = this.mensesDateDateString
            IcInfoAdd(values).then((res) => {
              if (res.success) {
                this.$message.success('新增成功')
                this.confirmLoading = false
                this.$emit('ok', values)
                this.handleCancel()
              } else {
                this.$message.error('新增失败：' + JSON.stringify(res.message))
              }
            }).finally((res) => {
              this.confirmLoading = false
            })
          } else {
            this.confirmLoading = false
          }
        })
      },
      onChangebirthday(date, dateString) {
        this.birthdayDateString = dateString
      },
      onChangeoperDate(date, dateString) {
        this.operDateDateString = dateString
      },
      onChangefoundDate(date, dateString) {
        this.foundDateDateString = dateString
      },
      onChangevalidDate(date, dateString) {
        this.validDateDateString = dateString
      },
      onChangemensesDate(date, dateString) {
        this.mensesDateDateString = dateString
      },
      handleCancel () {
        this.form.resetFields()
        this.visible = false
      }
    }
  }
</script>
